package com.hae.shop.common.util.annotation;

import com.hae.shop.common.util.MemberValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 限定参数只能取值的校验注解
 */
@Target(FIELD) //如果要多个应用，可以使用{METHOD, FIELD, ANNOTATION_TYPE}
@Retention(RUNTIME)
@Constraint(validatedBy = MemberValidator.class)
@Documented
public @interface MemberOf {
    String[] member() default {};

    Class<?>[] groups() default {}; //必须设定，否则会抛异常

    Class<? extends Payload>[] payload() default {};

    String message() default "参数值不在可取范围内！";
}
